//
//  CTUserWebViewController.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/6/18.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import "CTUserWebViewController.h"
#import "CTTabBarController.h"

//view
#import "CTUserWebView.h"

//function
#import "CTDebugManager.h"
#import "MobClick.h"

//model
#import "CTUserItem.h"

@interface CTUserWebViewController ()<CTUserWebViewDelegate>
{
    CTUserWebView * userWebView;
}
@end

@implementation CTUserWebViewController
@synthesize userItem,userWebViewType,levelsType;


- (void)dealloc
{
    [userWebView removeFromSuperview];
    userWebView = nil;
    
    userItem = nil;
    
    [CTDebugManager showDebugLogInfo:@"dealloc : CTUserWebViewController Is Removed!!!"];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    //统计
    [MobClick beginLogPageView:@"CTUserWebViewController"];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    //统计
    [MobClick endLogPageView:@"CTUserWebViewController"];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (userWebViewType == CTUserWebViewVCTypeVerifiedWeibo) {
        userWebView= [[CTUserWebView alloc] initWithType:CTUserWebViewTypeVerifiedWeibo];
        userWebView .loadUrl = userItem.verified_weibo;
    }else{
        userWebView= [[CTUserWebView alloc] initWithType:CTUserWebViewTypeVerifiedShop];
        userWebView .loadUrl = userItem.verified_shop;
    }
    
    userWebView .delegate = self;
    [self.view addSubview:userWebView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

#pragma mark - delegate -
-(void)backAction:(CTUserWebView *)view
{
    if (levelsType == CTUserWebViewLevelsFirst) {
        CTTabBarController * tabbarVC = (CTTabBarController *)self.navigationController.tabBarController;
        [tabbarVC showTabbarWithAnimate:YES];
    }
    [self.navigationController popViewControllerAnimated:YES];

}

@end
